<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <meta charset="utf-8" />
    <title>登录 | 和昌租售中心</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1.0" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <meta name="MobileOptimized" content="320">
    <!-- BEGIN GLOBAL MANDATORY STYLES -->
    <link href="${basePath}/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
    <!-- END GLOBAL MANDATORY STYLES -->
    <!-- BEGIN PAGE LEVEL STYLES -->
    <link rel="stylesheet" type="text/css" href="${basePath}/plugins/select2/select2_metro.css" />
    <link href="${basePath}/plugins/layer/skin/layer.css" rel="stylesheet">
    <!-- END PAGE LEVEL SCRIPTS -->
    <!-- BEGIN THEME STYLES -->
    <link href="${basePath}/css/style-metronic.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/css/style-responsive.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/css/plugins.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/css/themes/default.css" rel="stylesheet" type="text/css" id="style_color"/>
    <link href="${basePath}/css/pages/login.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/css/custom.css" rel="stylesheet" type="text/css"/>
    <!-- END THEME STYLES -->
    <link rel="shortcut icon" href="${basePath}/img/favicon.ico" />
</head>
<!-- BEGIN BODY -->
<body class="login">
<!-- BEGIN LOGO -->
<div class="logo">
</div>
<!-- END LOGO -->
<!-- BEGIN LOGIN -->
<div class="content">
    <!-- BEGIN LOGIN FORM -->
    <form id="loginForm" class="login-form" action="javascript:login()" method="post" autocomplete="off">
        <div class="form-group form-header">
            <span class="form-title">和昌租售中心</span>
        </div>
        <div class="form-group">
            <label class="control-label">登录名：</label>
            <div class="input-icon">
                <i class="fa fa-user"></i>
                <input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="请输入登录名" name="username" id="username" value="13812345678"/>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label">密码：</label>
            <div class="input-icon">
                <i class="fa fa-lock"></i>
                <input class="form-control placeholder-no-fix" type="password" autocomplete="off" placeholder="请输入密码" name="password" id="password" value="123456"/>
            </div>
        </div>
        <div class="form-actions">
            <button type="submit" class="btn blue" style="width: 100%">
                登录
            </button>
        </div>
    </form>
    <!-- END LOGIN FORM -->
</div>
<!-- END LOGIN -->
<!-- BEGIN COPYRIGHT -->
<div class="copyright">
</div>
<!-- END COPYRIGHT -->
<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- BEGIN CORE PLUGINS -->
<!--[if lt IE 9]>
<script src="${basePath}/plugins/respond.min.js"></script>
<script src="${basePath}/plugins/excanvas.min.js"></script>
<![endif]-->
<script src="${basePath}/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="${basePath}/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script src="${basePath}/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="${basePath}/plugins/bootstrap-hover-dropdown/twitter-bootstrap-hover-dropdown.min.js" type="text/javascript" ></script>
<script src="${basePath}/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="${basePath}/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="${basePath}/plugins/jquery.cookie.min.js" type="text/javascript"></script>
<script src="${basePath}/plugins/uniform/jquery.uniform.min.js" type="text/javascript" ></script>
<script src="${basePath}/plugins/jquery.form.min.js" type="text/javascript"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script src="${basePath}/plugins/jquery-validation/dist/jquery.validate.min.js" type="text/javascript"></script>
<script type="text/javascript" src="${basePath}/plugins/select2/select2.min.js"></script>
<script src="${basePath}/plugins/layer/layer.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="${basePath}/scripts/app.js" type="text/javascript"></script>
<script src="${basePath}/scripts/login.js" type="text/javascript"></script>
<script src="${basePath}/scripts/common.js" type="text/javascript"></script>
<!-- END PAGE LEVEL SCRIPTS -->
<script>
    jQuery(document).ready(function() {
        JudgeBroswer();
        App.init();
        Login.init();
//        $('#loginForm').ajaxForm({
//            dataType: 'json',
//            success: function (data) {
//                if (data.code==0) {
//                    location.href = "./index.htm";
//                } else {
//                    bootbox.alert(data.msg);
//                }
//            }
//        });
    });
    function JudgeBroswer() {
        if($.browser.msie) {
            var version=parseInt($.browser.version);
            if(version<8){
                layer.alert("您的浏览器版本过低<br/>请更新浏览器至最新版本或使用其他浏览器<br/>（建议使用最新版本搜狗、360或chrome浏览器）");
            }

//            alert("this is msie!"); //IE
        }
        else if($.browser.safari)
        {
//            alert("this is safari!"); //Safari
        }
        else if($.browser.mozilla)
        {
//            alert("this is mozilla!");  //Firefox
        }
        else if($.browser.opera) {
//            alert("this is opera");     //Opera
        }
    }
    function login(){
        var username = $("#username").val();
        var password = $("#password").val();
        var url=LoginURL;
        var data={
            username: username,
            password: password
        }
        $.ajax({
            async: false,
            url: url,
            dataType: 'jsonp',
            type: 'GET',
            jsonp: 'callback',
            data: data,
            success: function (json) {
//                var reg=new RegExp("NaN","g");
//                json=json.replace(reg,"null");
//                var obj = JSON.parse(json);
                if(json.code==0){
                    var resources=json.attach.resources;
                    var resourcesStr="";
                    for(var i=0;i<resources.length;i++){
                        resourcesStr+=resources[i].permission+",";
                    }
                    $.ajax({
                        url:"login.json",
                        async: false,
                        type:"post",
                        data:{
                            id:json.attach.userId,
                            name:json.attach.name,
                            store:json.attach.storeName,
                            resources:resourcesStr
                        },
                        async:false,
                        dataType:'txt',
                        success:function(data){
                        }
                    });
                    location.href = "./index.htm";
                }else{
                    layer.alert("您输入的登录名或密码不正确，请重新输入!");
                }
            }
        })
    }
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>